package com.hbnu.object;

/**
 * this关键字
 *
 * @author kittychen
 * @since 2025-09-12 17:36
 */
public class Person {

    private String username;

    public Person() {
        this("zhangsan");   // 构造方法调用其他构造方法时，this只能在首行
        method("lis");
    }

    public Person(String username) {
        this.username = username;
    }

    public void method(String username) {
        System.out.println(username);   // 输出局部变量username的值
        System.out.println(this.username);  // 输出成员变量username的值
    }

    public void method2() {
        System.out.println("=============");
        this.method("李四");
    }

    public static void main(String[] args) {
        Person person1 = new Person();
        Person person2 = new Person();

        person1.method2();
        person2.method2();

    }
}
